package com.atkusen.mini.mb.controller;

import java.util.Arrays;
import java.util.Map;

import com.atkusen.mini.common.entity.MiniEmployeeEntity;
import com.atkusen.mini.mb.service.MiniEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;


import com.atkusen.mini.common.utils.PageUtils;
import com.atkusen.mini.common.utils.R;



/**
 * 员工表
 *
 * @author Ghl
 * @email 807866012@qq.com
 * @date 2021-05-08 11:56:40
 */
@RestController
@RequestMapping("/private/miniemployee")
public class MiniEmployeeController {
    @Autowired
    private MiniEmployeeService miniEmployeeService;

    /**
     * 列表
     */
    @GetMapping("/list")
    //@RequiresPermissions("ware:miniemployee:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = miniEmployeeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @PreAuthorize("hasAnyAuthority('sys:user:get','sys:user:adds','sys:user:edits')")
    @GetMapping("/userinfo/{employeeId}")
    //@RequiresPermissions("ware:miniemployee:info")
    public R info(@PathVariable("employeeId") Integer employeeId){
		MiniEmployeeEntity miniEmployee = miniEmployeeService.getById(employeeId);

        return R.ok().put("miniEmployee", miniEmployee);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    //@RequiresPermissions("ware:miniemployee:save")
    public R save(@RequestBody MiniEmployeeEntity miniEmployee){
		miniEmployeeService.save(miniEmployee);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    //@RequiresPermissions("ware:miniemployee:update")
    public R update(@RequestBody MiniEmployeeEntity miniEmployee){
		miniEmployeeService.updateById(miniEmployee);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
   // @RequiresPermissions("ware:miniemployee:delete")
    public R delete(@RequestBody Integer[] employeeIds){
		miniEmployeeService.removeByIds(Arrays.asList(employeeIds));
        return R.ok();
    }

}
